package com.fliangyun.nsa.nsamanage.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * @author Rain
 * @date 2023年05月28日
 * @description
 */
@Service
public class SecureUserDetailsServiceImpl implements UserDetailsService {
    @Autowired
    private UserServiceImpl userService;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        UserDetails user = userService.getUserByMobile(username);
        if (user == null){
            throw new UsernameNotFoundException("账号不存在");
        }
        return user;
    }
}
